#!/bin/bash

basepath=$(cd `dirname $0`;pwd)
if [ -n "$1" ]; then
	basepath="$1"
else
	echo "  $basepath 下包含子目录"
	dirarr=()
	idx=0
	for dir in ${basepath}/*; do
		if [ -d $dir ]; then
			dirarr[$idx]="${dir##*/}"
			echo "    $[idx+1]: ${dirarr[$idx]}"
			idx=$[idx+1]
		fi
	done
	read -p "请输入工程目录序号:" idx
	basepath="$basepath/${dirarr[$[idx-1]]}"
fi

echo "$basepath"

if [ -d "$basepath/.idea" ]; then
	echo "delete $basepath/.idea"
	rm -rf "$basepath/.idea"
fi

if [ -d "$basepath/cmake-build-debug" ]; then
	echo "delete $basepath/cmake-build-debug"
	rm -rf "$basepath/cmake-build-debug"
fi

if [ -f "$basepath/${basepath##/}.iml" ]; then
	echo "delete $basepath/${basepath##/}.iml"
	rm "$basepath/${basepath##/}.iml"
fi

if [ -f "$basepath/app/app.iml" ]; then
	echo "delete $basepath/app/app.iml"
	rm "$basepath/app/app.iml"
fi

if [ -f "$basepath/libcocos2dx/libcocos2dx.iml" ]; then
	echo "delete $basepath/libcocos2dx/libcocos2dx.iml"
	rm "$basepath/libcocos2dx/libcocos2dx.iml"
fi
